<template>
	<view>
		<u-card>
			<view class=" u-p-r-30 u-p-l-30 u-m-t-20">
				<u-search placeholder="请输入关键词搜索" :clearabled="true" v-model="keyword" border-color="#606266"
					@custom="search" @search="search"></u-search>
			</view>
			<view class="" slot="head">
				<view class="wrap">
					<u-row>
						<u-col span="4" text-align="center">
							<view class=" weikaishi">
								<span>客户</span>
							</view>
						</u-col>
						<u-col span="4" text-align="center">
							<view class=" weikaishi">
								<span>单号</span>
							</view>
						</u-col>
						<u-col span="4" text-align="center">
							<view class=" weikaishi">
								<span>领取人</span>
							</view>
						</u-col>
					</u-row>
				</view>
			</view>
			<view class="" slot="body">
				<u-row v-for="(item,index) in dataList2" :key="index" @click="toput(item.id)">
					<u-col span="4" text-align="center">
						<view class="lanse u-m-t-10 huanhang">
							<span>{{item.getUnit}}</span>
						</view>
					</u-col>
					<u-col span="4" text-align="center">
						<view class="u-m-t-10 huanhang">
							<span>{{item.storageNumber}}</span>
						</view>
					</u-col>
					<u-col span="4" text-align="center">
						<view class="u-m-t-10 huanhang">
							<span>{{item.storageUserName}}</span>
						</view>
					</u-col>
					<u-col span="12" text-align="center">
						<view class="jiange">
						</view>
					</u-col>
				</u-row>
			</view>
		</u-card>
		<view>
			<u-toast ref="uToast" />
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				dataList2:[],
				keyword:'',
				appAgvTimeId:""
			}
		},
		onShow() {
			console.log('启动定时')
			this.getList2();
			this.appAgvTimeId = setInterval(() => {
				this.$http.post('/rest/HxStorageOut/appfindyilingquAgvJs', {}, {
					params: {
					},
					header: {
						'Authorization': uni.getStorageSync('token'),
					}
				}).then(res => {
					if (res.data.data != null&&res.data.data != "") {
						if(typeof this.appAgvTimeId != 'undefined' && this.appAgvTimeId != null && this.appAgvTimeId != ''){
							console.log('卸载定时')
							clearInterval(this.appAgvTimeId)
						}
						this.$Router.push({
							name: 'hx_storage_agv_detail',
							params: {
								id: res.data.data.id
							},
						})
					} 
				})
			}, 10000)
		},
		onLoad() {
			//#ifdef H5 || APP-PLUS
			this.flex = 'u-flex'
			//#endif
		},
		onUnload() {
			if(typeof this.appAgvTimeId != 'undefined' && this.appAgvTimeId != null && this.appAgvTimeId != ''){
				console.log('卸载定时')
				clearInterval(this.appAgvTimeId)
			}
		},
		methods: {
			toput(id) {
				if(typeof this.appAgvTimeId != 'undefined' && this.appAgvTimeId != null && this.appAgvTimeId != ''){
					console.log('卸载定时')
					clearInterval(this.appAgvTimeId)
				}
				this.$Router.push({
					name: 'hx_storage_agv_detail',
					params: {
						id: id
					},
				})
			},
			getList2(){
				uni.showLoading({
					title: '加载中'
				});
				this.$http.post('/rest/HxStorageOut/appfindyilingquAgv', {}, {
					params: {
						keyword: this.keyword
					},
					header: {
						'Authorization': uni.getStorageSync('token'),
					}
				}).then(res => {
					uni.hideLoading();
					if (res.data.success) {
						this.dataList2 = res.data.data
					} else {
						uni.showToast({
							title: res.data.message,
							duration: 2000,
							icon:'none',
						});
					}
				})
			},
			search(e) {
				this.getList2();
			}
		}
	}
</script>


<style lang="scss">
	.u-body-item {
		padding: 20rpx 15rpx;
	}

	.wrap {
		padding: 0rpx 12rpx;
	}

	.u-row {
		margin: 10rpx 2rpx;
	}

	.weikaishi2 {
		font-size: 34rpx;
	}

	.weikaishi3 {
		font-size: 30rpx;
	}

	.jiange {
		border-bottom: 1px solid #ebebeb;
	}

	.huanhang {
		word-break: break-all;
	}

	.baise {
		background-color: #2979ff;
		color: #ffffff;
		font-size: 45rpx;
	}
</style>